// pages/oneInspection/oneInspection.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    inspection: {},
    line: {},
    startPole:{},
    endPole:{},
    cancel:["否","是"],
    sysConfig:{},
    detail:{},
    insDetail:{},
    isBug:['无','有'],
    bugI:{},
    bugT:{},
    uid:0
  },
  receipt(){
    wx.navigateTo({
      url: '/pages/receiptAdd/receiptAdd?mid='+this.data.inspection.id+'&uid='+this.data.uid,
    })
  },
  updata(){
    //把json对象打包成字符串
    var inspection=JSON.stringify(this.data.inspection) 
    var line=JSON.stringify(this.data.line)
    var sysConfig=JSON.stringify(this.data.sysConfig)
    wx.navigateTo({
      url: '/pages/inspectionUp/inspectionUp?inspection='+inspection+'&line='+line+'&sysConfig='+sysConfig,
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    wx.setNavigationBarTitle({
      title: '巡检任务' 
    })
    this.setData({
      uid:options.uid
    })
    wx.request({
      url: 'http://127.0.0.1:8080/selectInspectionByid?id=' + options.id,
      success: res => {
        //console.log(res)
        this.setData({
          inspection: res.data,
        })
      }
    })
    setTimeout(() => {
      wx.request({
        url: 'http://127.0.0.1:8080/selectPsLineInfoById?id=' + this.data.inspection.lineid,
        success:r=>{
          this.setData({
            line: r.data,
          })
        }
      })
      wx.request({
        url: 'http://127.0.0.1:8080/selectPoleById?id='+ this.data.inspection.startpole,
        success:sp=>{
          this.setData({
            startPole:sp.data
          })
        }
      })
      wx.request({
        url: 'http://127.0.0.1:8080/selectPoleById?id='+ this.data.inspection.endpole,
        success:ep=>{
          this.setData({
            endPole:ep.data
          })
        }
      })
      wx.request({
        url: 'http://127.0.0.1:8080/selectSystemconfigByid?id='+ this.data.inspection.taskStatusId,
        success:tid=>{
          //console.log(tid)
          this.setData({
            sysConfig:tid.data
          })
        }
      })
      wx.request({
        url: 'http://127.0.0.1:8080/selectDetailByMainId?id='+ this.data.inspection.id,
        success:det=>{
          //console.log(det)
          this.setData({
            detail:det.data
          })
        }
      })
      wx.request({
        url: 'http://127.0.0.1:8080/selectInsDetailByMainId?id='+ this.data.inspection.id,
        success:insd=>{
          //console.log(insd)
          this.setData({
            insDetail:insd.data
          })
        }
      })
      setTimeout(() => {
        wx.request({
          url: 'http://127.0.0.1:8080/selectSystemconfigByid?id='+ this.data.insDetail.bugLevelId,
          success:bid=>{
            console.log(bid)
            this.setData({
              bugI:bid.data
            })
          }
        })
        wx.request({
          url: 'http://127.0.0.1:8080/selectSystemconfigByid?id='+ this.data.insDetail.bugTypeId,
          success:bt=>{
            console.log(bt)
            this.setData({
              bugT:bt.data
            })
          }
        })
      }, 200);
    }, 100);
    

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})